from django.db import models

# Create your models here.\

def domTreeTreeDefault():
    return {
        'tag': 'div',
        'attr': {
            'id': 'canvas',
            'name': 'canvas',
            'onClick': '',
            'style': {},
            'class': {
                'web-page': True,
                'highlighted': True
            },
            'layer': 0,
            'key': False
        },
        'children': [],
        'parentId': None
    }

class Project(models.Model):
    user_id = models.BigIntegerField()
    project_id = models.BigAutoField(primary_key=True)
    title = models.CharField(max_length=255)
    introduction = models.CharField(max_length=255)
    create_time = models.DateTimeField(null=True)
    modify_time = models.DateTimeField(null=True)
    type_list = [
        (1, 'web')
    ]
    type = models.IntegerField(choices=type_list)
    isCollect = models.BooleanField()
    isDelete = models.BooleanField()

    # design界面新增，也可分离出去
    htmlCode = models.TextField(null=True, verbose_name='html代码')
    jsCode = models.TextField(null=True, verbose_name='js代码')
    domTreeMap = models.JSONField(null=True, default=domTreeTreeDefault, verbose_name='DOM树映射表')
    count = models.IntegerField(default=1, verbose_name='命名总元素数')
